package com.stylefeng.guns.modular.product.warpper;

import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.FmtMicrometer;

import java.util.Date;
import java.util.List;
import java.util.Map;

public class FxTotalReportWarpper extends BaseControllerWarpper {

    public FxTotalReportWarpper(List<Map<String, Object>> list){
        super(list);
    }
    @Override
    protected void warpTheMap(Map<String, Object> map) {
        Double counterValue = (Double) map.get("counterValue");
        Double notional = (Double) map.get("notional");
        if(notional != null && counterValue != null)
            map.put("rate", FmtMicrometer.fmtMicrometer(counterValue/notional, 7, true));
        else
            map.put("rate", null);

        map.put("valueDate",DateUtil.getDay((Date) map.get("valueDate")));

        if(null != notional)
            map.put("notional", FmtMicrometer.fmtMicrometer(notional, 2, true));

        if(null != counterValue)
            map.put("counterValue", FmtMicrometer.fmtMicrometer(counterValue, 2, true));

        if(map.get("mtmUsd") != null)
            map.put("mtmUsd", FmtMicrometer.fmtMicrometer((Double)map.get("mtmUsd"), 0, true));

    }
}
